package com.rzj.sys_lab_assistant.service.impl;

import com.rzj.sys_lab_assistant.dao.AdminMapper;
import com.rzj.sys_lab_assistant.entity.Admin;
import com.rzj.sys_lab_assistant.entity.Admin;
import com.rzj.sys_lab_assistant.service.IAdminService;
import com.rzj.sys_lab_assistant.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: sys_lab_assistant
 * @description:
 * @author: 作者
 * @create: 2021-06-29 16:52
 */
@Service
public class AdminServiceImpl implements IAdminService {

    @Autowired
    AdminMapper adminMapper;

    TimeUtils timeUtils;

    @Override
    public List<Admin> listAdmins() {
        return adminMapper.listAdmins();
    }

    @Override
    public Admin getAdminById(String account) {
        return adminMapper.getAdminById(account);
    }

    @Override
    public int saveAdmin(Admin admin) {
        admin.setCreateTime(timeUtils.getTime());
        admin.setModifyTime(timeUtils.getTime());

        return adminMapper.saveAdmin(admin);
    }

    @Override
    public int updateAdmin(Admin admin) {
        admin.setModifyTime(timeUtils.getTime());
        return adminMapper.updateAdmin(admin);
    }

    @Override
    public int deleteAdmin(String account) {
        return adminMapper.deleteAdmin(account);
    }
}
